package com.qf.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author Wy
 * @version V1.0
 * @Project MavenDemo
 * @Package com.qf.filter
 * @Description:
 * @Date 2022/7/7 19:11
 */
@Component
public class MyGlobalFilter2 implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("---第二个过滤器");
        //放行请求, 如果有下一个过滤器继续执行, 如果没有下一个过滤器, 放行请求
        return chain.filter(exchange);
    }


    /**
     * 返回的数字, 就是如果有多个过滤器, 他们的执行顺序
     * @return
     */
    @Override
    public int getOrder() {
        return 1;
    }
}
